<template>
  <div id="OrdersTitle">
    <g-details
      :inputConfig="inputConfig"
      :detailData="inputData"
      :rules="rules"
      @pop="setdata"
    ></g-details>
  </div>
</template>

<script>
import baseMixin from "@/mixins/BaseMixin";

export default {
  props: {
    inputData: {
      type: Object,
    },
  },
  mixins: [baseMixin],
  name: "OrdersTitle",
  data() {
    return {
      inputConfig: [
        {
          type: "input",
          label: this.$t('out.orderkey'),
          disabled: true,
          props: "orderkey",
        },
        {
          type: "select",
          label: this.$t('bill.orderType'),
          disabled: false,
          props: "type",
          options: this.getOptions("querycodeLkup/ORDERTYPE"),
        },
        {
          type: "select",
          label: this.$t('config.asnStatus'),
          disabled: true,
          props: "status",
          options: this.getOptions("queryOrderStatusDropDown"),
        },
        {
          type: "date",
          label: this.$t('in.asnDate'),
          disabled: !this.$route.query.newFlag,
          props: "orderdate",
        },
        {
          type: "select",
          label: this.$t('in.priority'),
          disabled: false,
          props: "priority",
          options: this.getOptions("querycodeLkup/ORDRPRIOR"),
        },
        {
          type: "select",
          label: this.$t('out.rtxexternaltype1'),
          disabled: !this.$route.query.newFlag,
          props: "rtxexternaltype",
          options: this.getOptions("querycodeLkup/RTXEXTERNALTYPE"),
          break:true
        },
        {
          type: "table",
          label: this.$t('config.shipper'),
          disabled: !this.$route.query.newFlag,
          props: "storerkey",
          tableConfig: [
            {
              label: this.$t('config.shipper'),
              prop: "storerkey",
              input: "input",
            },
            {
              label: this.$t('config.company'),
              prop: "company",
              input: "input",
            },
            {
              label: this.$t('config.city'),
              prop: "city",
              input: "input",
            },
            {
              label: this.$t('config.provice'),
              prop: "state",
              input: "input",
            },
            {
              label: this.$t('config.postcode'),
              prop: "zip",
              input: "input",
            },
            {
              label: this.$t('config.contact'),
              prop: "contact",
              input: "input",
            },
            {
              label: this.$t('config.phone'),
              prop: "phone",
              input: "input",
            },
          ],
          url: `queryStorer/1/?/${this.$store.state.wms}`,
          filterKey:"storerkey",
        },
        {
          type: "table",
          label: this.$t('config.carrierCode'),
          props: "carriercode",
          tableConfig: [
            {
              label: this.$t('config.shipper'),
              prop: "storerkey",
              input: "input",
            },
            {
              label: this.$t('config.company'),
              prop: "company",
              input: "input",
            },
            {
              label: this.$t('config.city'),
              prop: "city",
              input: "input",
            },
            {
              label: this.$t('config.provice'),
              prop: "state",
              input: "input",
            },
            {
              label: this.$t('config.postcode'),
              prop: "zip",
              input: "input",
            },
            {
              label: this.$t('config.contact'),
              prop: "contact",
              input: "input",
            },
            {
              label: this.$t('config.phone'),
              prop: "phone",
              input: "input",
            },
          ],
          url: `queryStorer/3/?/${this.$store.state.wms}`,
          filterKey:"storerkey",
        },
        {
          type: "select",
          label: this.$t('in.receiptfinishflag'),
          disabled: false,
          props: "orderfinishflag",
          options: [
            { code: "P", description: "P" },
            { code: "PS", description: "PS" },
            { code: "PF", description: "PF" },
            { code: "S", description: "S" },
          ],
        },
        {
          type: "select",
          label: this.$t('config.allocaStrategy'),
          disabled: false,
          props: "allocatestrategykey",
          options: this.getOptions("queryAllocatestrategyDropDown"),
        },
        {
          type: "table",
          label: this.$t('config.depart'),
          props: "dept_name",
          tableConfig: [
            {
              label: this.$t('config.deptNo'),
              prop: "deptNo",
              input: "input",
            },
            {
              label: this.$t('config.departName'),
              prop: "deptName",
              input: "input",
            },
          ],
          url: `baFactoryDept/selectBaFactoryDeptList`,
          filterKey:"deptName",
        },
        {
          type: "table",
          label: this.$t('config.deptLine'),
          props: "dept_line_name",
          tableConfig: [
            {
              label: this.$t('config.departName'),
              prop: "deptName",
              input: "input",
            },
            {
              label: this.$t('config.deptLineNo'),
              prop: "deptLineNo",
              input: "input",
            },
            {
              label: this.$t('config.deptLineName'),
              prop: "deptLineName",
              input: "input",
            },
          ],
          url: ``,
          filterKey:"deptLineName",
          break:true
        },
        {
          type: "input",
          label: this.$t('in.pokey'),
          disabled: !this.$route.query.newFlag,
          props: "referencenum",
        },
        {
          type: "input",
          label: this.$t('out.externorderkey',{no:1}),
          disabled: false,
          props: "externorderkey",
        },
        {
          type: "input",
          label: this.$t('out.externorderkey',{no:2}),
          disabled: !this.$route.query.newFlag,
          props: "externalorderkey2",
        },
        {
          type: "input",
          label: this.$t('out.pokey'),
          disabled: !this.$route.query.newFlag,
          props: "pokey",
        },
        {
          type: "input",
          label: this.$t('out.ordergroup'),
          disabled: false,
          props: "ordergroup",
          break:true
        },
        {
          type: "input",
          label: this.$t('config.deliveryAddress'),
          disabled: !this.$route.query.newFlag,
          props: "consigneekey",
        },
        {
          type: "input",
          label: this.$t('out.route'),
          disabled: false,
          props: "route",
        },
        {
          type: "input",
          label: this.$t('in.trailernumber'),
          disabled: false,
          props: "trailernumber",
        },
        {
          type: "input",
          label: this.$t('out.stop'),
          disabled: false,
          props: "stop",
        },
        {
          type: "date",
          label: this.$t('out.promisedshipdate'),
          disabled: !this.$route.query.newFlag,
          props: "promisedshipdate",
        },
        {
          type: "date",
          label: this.$t('out.actualshipdate'),
          disabled: !this.$route.query.newFlag,
          props: "actualshipdate",
          break:true
        },
        {
          type: "checkbox",
          label: this.$t('out.suspendedindicator'),
          props: "suspendedindicator",
          disabled: !this.$route.query.newFlag,
        },
        {
          type: "checkbox",
          label: this.$t('out.allocation'),
          props: "apportion",
          disabled: !this.$route.query.newFlag,
        },
      ],
      rules: {
        orderkey: [{ required: true, trigger: "blur" }],
        storerkey: [{ required: true, trigger: "change" }],
        priority: [{ required: true, trigger: "blur" }],
        type: [{ required: true, trigger: "blur" }],
      },
      detailData: {},
    };
  },
  computed: {},
  methods: {
    //勾选暂挂订单
    setsuspendedindicator() {
      this.inputData.suspendedindicator = "1";
    },
    setdata(data, close, listId) {
      if (listId == "storerkey") {
        this.inputData.storerkey = data.storerkey;
      }
      if (listId == "carriercode") {
        this.inputData.carriercode = data.storerkey;
      }
      if (listId == "dept_name") {
        if(this.inputData.dept_id != data.id){
          this.inputData.dept_line_name = "";
          this.inputData.dept_line_id = "";
        }
        this.inputData.dept_name = data.deptName;
        this.inputData.dept_id = data.id;

      }
      if (listId == "dept_line_name") {
        this.inputData.dept_name = data.deptName;
        this.inputData.dept_id = data.deptId;
        this.inputData.dept_line_name = data.deptLineName;
        this.inputData.dept_line_id = data.id;
      }
      close(false);
    },
  },
  mounted() {},
  watch: {
    "inputData.dept_id": {
      handler(data) {
        this.inputConfig.forEach((item) => {
          if (item.props == "dept_line_name") {
            if(data == ""){
              item.url = `/baFactoryDeptLine/selectBaFactoryDeptLineList`;
            }else{
              item.url = `/baFactoryDeptLine/selectBaFactoryDeptLineList/${data}`;
            }
          }
        });
      },
      deep: true,
      immediate: true,
    },
  },
};
</script>

<style scoped></style>
